<?php
/**
 * Created by PhpStorm.
 * User: heqian
 * Date: 18-9-28
 * Time: 上午10:04
 */
parse_str("appid=8000016&sign=e64a915b4a6c1d1cc4f27596354b071&timestamp=1538100075&deviceid=12346434&devicesecret=d15ebbny&printdata=123",$_POST);
parse_str("appid=8000016&sign=1edafe561efa325f90e2cc8f989e4c83&timestamp=1538100082&deviceid=12346434&devicesecret=d15ebbny&printdata=123",$_POST);

parse_str(urldecode("appid=8000020&sign=162f1f57812ee6167bd36b174ff6a4d9&timestamp=1539422976&deviceid=12346432&devicesecret=r998i3j6&printdata=name%253D%25E6%2588%2590%25E6%259D%25B0"),$_POST);

var_dump($_POST);


function checkSign($param, $sign, $appsecret)
{
    unset($param['sign']);

    $stringtoSigned = '';

    ksort($param);

    foreach ($param as $k => $v) {

        $stringtoSigned .= $k . $v;

    }

    $stringtoSigned .= $appsecret;

    var_dump($stringtoSigned);

    echo md5($stringtoSigned);

    return $sign == md5($stringtoSigned);
}

$appsecret = '2cd1a7c4a3aa620a07c857f0443805f4';

$appsecret = '70b2ae7c69909601965ae7abe2160a3b';

var_dump(checkSign($_POST,$_POST['sign'],$appsecret));